import request from './request';
import mockRequest from './mockRequest';



//获取商品详情
export const reqDetailInfo = (skuId) => {
    return request({
        url: `/get/item/${skuId}`,
        method: 'get'
    }) 
}


export const reqSearchInfo = (searchParams) => {
    return request({
        url: '/post/list',
        method: 'post',
        data: searchParams,//用户搜索参数
    })
}

export const reqCategoryList = () => {
    return request({
        url: '/get/product/getBaseCategoryList',
        method: 'get'
    })
}

export const reqGetCode = (phone) => {
    return request({
        url: `/get/user/passport/sendCode/${phone}`,
        method: 'get'
    })
}
//请求用户登录
export const reqUserLogin = (userInfo) => {
    console.log(userInfo);
    return request({
        url: `/post/user/passport/login`,
        method: 'post',
        data: userInfo
    })
}
//请求添加购物车 + 修改购物车数量
// export const reqAddOrUpdateShopCart = (skuId,skuNum) => {
//   return request({
//     url:`/post/cart/addToCart/${ skuId }/${ skuNum }`,
//     method:'post'
//   })
// }
export const reqAddOrUpdateShopCart = (skuId,skuNum) => {
    console.log(skuId,skuNum);
  return request({
    url:`/post/cart/addToCart/${ skuId }/${ skuNum }`,
    method:'post',
    data: {
       
    }

  })
}

//购物车列表获取
export const reqShopCartInfo = () => {
    return request({
        url: '/get/cart/cartList',
        method: 'get'
    })
}

//请求修改购物车选择状态
export const reqUpdateCartIscheck = (skuId,isChecked) => {
    return request({
        url: `/get/cart/checkCart/${skuId}/${isChecked}`,
        method: 'get'
    })
    
}
//请求删除
export const reqDeleteShopCart = (skuId) => {
    return request({
        url: `/delete/cart/deleteCart/${skuId}`,
        method: 'delete',
        data: {
        }
    })
}

export const reqUserRegister = (userInfo) => {
    return request({
        url: `/post/user/passport/register`,
        method: 'post',
        data: userInfo
    })
}

export const reqGetUserInfo = () => {
    return request({
        url: `/get/user/passport/auth/getUserInfo`,
        method: 'get',
    })
}

export const reqUserLogout = () => {
    return request({
        url: `/get/user/passport/logout`,
        method: 'get',
    })
}
export  const reqUserAddressList = () => {
    return request({
        url: `/get/user/userAddress/auth/findUserAddressList`,
        method: 'get',
    })
}
//订单数据
export const reqTradeInfo = () => {
    return request({
        url: `/get/order/auth/trade`,
        method: 'get',
    })
}

export const reqSubmitOrder = (tradeNo,tradeInfo) => {
    return request({
        url: `/post/order/auth/submitOrder?tradeNo=${tradeNo}`,
        method: 'post',
        data: tradeInfo
    })
}
//支付信息
export const reqPayInfo = (orderId) => {
    return request({
        url: `/get/payment/weixin/createNative/${orderId}`,
        method: 'get',
    })
}

export const reqPayStatus = (orderId) => {
    return request({
        url: `/get/payment/weixin/queryPayStatus/${orderId}`,
        method: 'get',
    })
}

export const reqMyOrderInfo = (page,limit) => {
    return request({
        url: `/get/order/auth/${page}/${limit}`,
        method: 'get',
    })
}
//使用模拟接口
export const reqBannerList = () => {
    return mockRequest({
        url: '/banner',
        method: 'get'
    })
}

export const reqFloorList = () => {
    return mockRequest({
        url: '/floor',
        method: 'get'
    })
}